<template>
	<view class="uni-padding-wrap">
		<view class="uni-form-item uni-row">
			<view class="title">
				国家/地区<text class="text-danger">*</text>
				</view>
			<view class="uni-list-cell-db">
				<picker @change="bindPickerChange" :value="index" :range="array">
					<view class="uni-input">{{array[index]}}</view>
				</picker>
			</view>
		</view>
		<view class="uni-form-item uni-row">
			<view class="title">
				账号<text class="text-danger">*</text>
			</view>
			<input class="uni-input" focus placeholder="请输入账号" @input="inputAccount"/>
		</view>
		<view class="uni-form-item uni-row">
			<view class="title">
				手机号<text class="text-danger">*</text>
			</view>
			<input class="uni-input" focus placeholder="请输入手机号" @input="inputPhone"/>
			<a href="" class="href">获取验证码</a>
		</view>
		<view class="uni-form-item uni-row">
			<view class="title">
				验证码<text class="text-danger">*</text>
			</view>
			<input class="uni-input" focus placeholder="请输入验证码" @input="inputCode"/>
		</view>
		<view class="uni-form-item uni-row">
			<view class="title">
				密码<text class="text-danger">*</text>
			</view>
			<input class="uni-input" focus placeholder="请输入密码" @input="inputPwd"/>
		</view>
		<view class="uni-form-item uni-row">
			<view class="title">
				确认密码<text class="text-danger">*</text>
			</view>
			<input class="uni-input" focus placeholder="请再次输入密码" @input="checkPwd"/>
		</view>
		<view class="uni-form-regbtn">
			<button type="primary" class="register-btn" @click="register()">注册</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				array: ['中国', '美国', '巴西', '日本'],
				index: 1,
				userdata: [],
			}
		},
		methods: {
			bindPickerChange: function(e) {
				this.index = e.detail.value
				this.userdata["area"] = this.array[this.index];
			},
			inputAccount(e){
				this.userdata["account"] = e.detail.value
			},
			inputPhone(e) {
				this.userdata["phone"] = e.detail.value
			},
			inputCode(e) {
				this.userdata["code"] = e.detail.value
			},
			inputPwd(e) {
				this.userdata["newpwd"] = e.detail.value
			},
			checkPwd(e) {
				this.userdata["checkpwd"] = e.detail.value
			},
			register(e) {
				// console.log(this.userdata)
				if(true) {
					uni.navigateTo({
						url: '../../pages/login/login?username='+ this.userdata['account'] + '&pwd=' + this.userdata['newpwd'],
						success: res => {},
						fail: () => {},
						complete: () => {}
					});
				}
			},
		},
		onShow() {
			uni.setNavigationBarColor({
				backgroundColor: "#09BB07",
				frontColor: "#ffffff"
			})
		}
	}
</script>

<style lang="scss">
	.uni-form-item {
		border-bottom: 1px solid #D9D9D9;
	}

	.uni-row {
		input {
			text-align: left;
		}

		.title {
			line-height: 60upx;
			text-align: left;
			width: 160upx;
			.text-danger {
				color: #dc3545;
			}
		}

		.href {
			color: green;
			line-height: 80upx;
			text-decoration: none;
			margin-right: 20upx;
		}

		.href:active {
			color: #aaaaff;
		}
	}

	.uni-form-regbtn {
		width: 612upx;
		margin: 0 auto;
		margin-top: 64upx;
	}
</style>